/**
 * 预定一个字符串S。按如下构造字符串T
 * S[1...k] S转置 S[k+1...N]
 * 现在给定T，问是否能还原S
 * 
 * for i in [1...N]:
 *    S[1...K]的哈希 * Seed的N-i-1次方 + S[k+1...N]的哈希
 *    看这个哈希是否等于中间部分转置的哈希即可
 * 
 * 用自然溢出始终有5个点过不了，必须取模
 */
#include <bits/stdc++.h>
using namespace std;

namespace ZIFUCHUAN
{

int const UN = 2;

using hash_t = array<long long, UN>; // 不能用ULL，否则减法可能有问题
// 10007, 10093
hash_t const Seeds {13313, 10}; // 10用来观察效果
hash_t const ZERO {0, 0};
hash_t const ONE {1, 1};
hash_t const MOD {998244353LL, 998244353LL};

hash_t const operator + (const hash_t & a, const hash_t & b){
    hash_t ans;
    for(int i=0;i<UN;++i) ans[i] = (a[i] + b[i]) % MOD[i];
    return ans;
}

hash_t const operator - (const hash_t & a, const hash_t & b){
    hash_t ans;
    for(int i=0;i<UN;++i) ans[i] = ((a[i] - b[i]) % MOD[i] + MOD[i]) % MOD[i];
    return ans;
}

hash_t const operator * (const hash_t & a, const hash_t & b){
    hash_t ans;
    for(int i=0;i<UN;++i) ans[i] = a[i] * b[i] % MOD[i];
    return ans;
}

ostream & operator << (ostream & os, const hash_t & h) {
    os << "[";
    for(int i=0;i<UN;++i){
        os << h[i];
        if(i + 1 == UN) os << "]";
        os << ",";
    }
    return os;
}

vector<hash_t> Power; // 进制的幂值
void initPower(int n){
    Power.clear();
    Power.reserve(n + 1);
    Power.emplace_back(ONE);

    for(int i=1;i<=n;++i){
        Power.emplace_back(Power.back() * Seeds);
    }

    return;
}

hash_t tr(char c) {
    hash_t ans;
    for(int i=0;i<UN;++i) {
        // ans[i] = c;
        ans[i] = c - 'a' + 1;
    }
    return ans;
}

template<typename IT = string::const_iterator>
struct StrHash
{

/// 
StrHash(IT begin, int n):N(n){
    H.clear();
    H.reserve(N + 1);
    H.emplace_back(ZERO);
    for(int i=1;i<=N;++i){
        H.emplace_back(H.back() * Seeds + tr(*begin++));
    }
    return;
}

/// s[a...b]的哈希, a和b是0-index
hash_t get(int a, int b) const {
    assert(0 <= a and a <= b and b < N);
    // ++a, ++ b;
    // return H[b] - H[a - 1] * Power[b - a + 1];
    return H[b + 1] - H[a] * Power[b - a + 1];
}

vector<hash_t> H;
int N;

};


}

/// 模板偏特化
template<> struct std::hash<ZIFUCHUAN::hash_t> {
    std::size_t operator() (const ZIFUCHUAN::hash_t & p) const {
        std::size_t ret = 0;
        for(auto i : p) ret = ret * 9973 + i;
        return ret;
    }
};

using namespace ZIFUCHUAN;

int N;
string T;
string TT;

void work(){
    initPower(2E6 + 1100);
    
    cin >> N >> T;
    TT = T;
    reverse(TT.begin(), TT.end());

    StrHash<> z(T.begin(), N + N);
    StrHash<> f(TT.begin(), N + N);

    if(z.get(N, N + N - 1) == f.get(N, N + N - 1)){
        cout << T.substr(N, N) << endl;
        cout << "0" << endl;
        return;
    }

    for(int i=0;i<N;++i){
        auto t = z.get(0, i);
        t = t * Power[N - i - 1];
        if(i + 1 != N) t = t + z.get(N + i + 1, N + N - 1);

        int u = i + 1;
        int v = i + N;

        u = N + N - u - 1;
        v = N + N - v - 1;
        swap(u, v);

        auto tmp = f.get(u, v);
        if(t == tmp){
            cout << TT.substr(u, N) << endl;
            cout << i + 1 << endl;
            return;
        }
    }

    cout << "-1" << endl;
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) work();
    return 0;
}